﻿<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title></title>
    <script src="~/js/frame.js"></script>
</head>
<body>
    <div class="container-fluid">
        <form id="form">
            <div class="formrow">
                <div class="col-xs-12">
                    <div class="formtitle required">所属部门</div>
                    <div class="formcontent">
                        <cloud-tree id="OUGuid" url="tree" control-type="selectou" select-type="single" readonly></cloud-tree>
                    </div>
                </div>
            </div>
            <div class="formrow">
                <div class="col-xs-6">
                    <div class="formtitle required">登录名</div>
                    <div class="formcontent">
                        <input name="LoginID" type="text" class="form-control required" placeholder="" disabled>
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="formtitle required">人员姓名</div>
                    <div class="formcontent">
                        <input name="DisplayName" type="text" class="form-control required" disabled>
                    </div>
                </div>
            </div>
            <div class="formrow">
                <div class="col-xs-6">
                    <div class="formtitle">性别</div>
                    <div class="formcontent">
                        <div class="formcontent">
                            <label class="radio-inline">
                                <input type="radio" name="Sex" checked value="100">男
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="Sex" value="200">女
                            </label>
                        </div>
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="formtitle">手机号码</div>
                    <div class="formcontent">
                        <input name="Mobile" type="text" class="form-control">
                    </div>
                </div>
            </div>
            <div class="formrow">
                <div class="col-xs-6">
                    <div class="formtitle">邮箱</div>
                    <div class="formcontent">
                        <input name="Email" type="text" class="form-control" placeholder="">
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="formtitle">办公电话</div>
                    <div class="formcontent">
                        <input name="TelePhoneOffice" type="text" class="form-control">
                    </div>
                </div>
            </div>
            <div class="formrow">
                <div class="col-xs-6">
                    <div class="formtitle">家庭电话</div>
                    <div class="formcontent">
                        <input name="TelePhoneHome" type="text" class="form-control" placeholder="">
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="formtitle">状态</div>
                    <div class="formcontent">
                        <label class="radio-inline">
                            <input type="radio" name="Enable" checked value="100" disabled>启用
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="Enable" value="200" disabled>禁用
                        </label>
                    </div>
                </div>
            </div>
            <div class="formrow">
                <div class="col-xs-6">
                    <div class="formtitle">身份证号码</div>
                    <div class="formcontent">
                        <input name="IdentityCardNum" type="text" class="form-control" placeholder="">
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="formtitle">车牌号</div>
                    <div class="formcontent">
                        <input name="CarNum" type="text" class="form-control">
                    </div>
                </div>
            </div>
            <div class="formrow">
                <div class="col-xs-6">
                    <div class="formtitle">生日</div>
                    <div class="formcontent">
                        <input name="Birthday" type="text" class="form-control form-date" placeholder="">
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="formtitle">QQ</div>
                    <div class="formcontent">
                        <input name="QQNumber" type="text" class="form-control">
                    </div>
                </div>
            </div>
            <div class="formrow">
                <div class="col-xs-6">
                    <div class="formtitle">邮政地址</div>
                    <div class="formcontent">
                        <input name="PostalAddress" type="text" class="form-control" placeholder="">
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="formtitle">邮政号码</div>
                    <div class="formcontent">
                        <input name="PostalCode" type="text" class="form-control">
                    </div>
                </div>
            </div>
            <div class="formrow">
                <div class="col-xs-6">
                    <div class="formtitle">上传头像</div>
                    <div class="formcontent">
                        <img onerror="this.src='../../../images/person.png'"  style="width: 100px; height: 100px;" id="HeadImg">
                        <button class="btn cloudbtn" type="button" onclick="SelectImage()">选择图片</button>
                        <input type="file" style="display:none" id="FileSelect" accept=".jpg,.png,.jpeg" onchange="FileChange()"/>
                    </div>
                </div>
            </div>
            <div style="display:none">
                <input name="UserGuid" type="text" class="form-control" placeholder="">
            </div>
            <div class="row formbtnop">
                <button class="btn btn-primary cloudbtn" type="button" onclick="Save()">保 存</button>
                <button class="btn cloudbtn" type="button" onclick="Close()">关 闭</button>
            </div>
        </form>
    </div>
    <script>
        var UploadAttachUrl = GetRootPath() + "frame/base/attach/uploadKeepOneAttach"
        var AttachUrl = GetRootPath() + "frame/base/attach/readfile?AttachGuid=" + GetUrlParam("userguid");
        var formvalidator = $("#form").validate();
        $(function () {
            LoadDetail();
            $("#HeadImg").attr("src", AttachUrl + "&version=" + GetNewGuid());
        })
        function LoadDetail() {
            var param = { "UserGuid": GetUrlParam("userguid") }
            CloudPost(param, "opdetail", function (res) {
                if (res.code == 0) {
                    $("#form").SetForm(res.data);
                    $("#OUGuid").attr("selectvalue", res.data.OUGuid);
                    RenderTree();
                }
            })
        }

        function Save() {
            if (formvalidator.form()) {
                var param = $("#form").GetForm();
                param.OUGuid = GetTreeSelectValue("OUGuid");
                CloudPost(param, "opupdate", function (res) {
                    if (res.code == 0) {
                        OpenSuccess("保存成功！", function () {
                            CloseDialog();
                        })
                    } else {
                        OpenFail(res.data)
                    }
                })
            }
        }
        function SelectImage() {
            $("#FileSelect").click();
        }
        function FileChange() {
            var fileUpload = $("#FileSelect").get(0);
            var files = fileUpload.files;
            var formData = new FormData();
            for (var i = 0; i < files.length; i++) {
                formData.append(files[i].name, files[i]);
            }
            formData.append("GroupGuid", GetUrlParam("userguid"));
            formData.append("GroupType", "HeadImg");
            formData.append("AttachGuid", GetUrlParam("userguid"))
            CloudPostFile(formData, UploadAttachUrl, function (res) {
                if (res.code == 0) {
                    $("#HeadImg").attr("src", AttachUrl + "&version=" + GetNewGuid());
                } else {
                    OpenFail(res.data);
                }
            })
            $("#FileSelect").val('');
        }
        function Close() {
            CloseDialog();
        }
    </script>
</body>
</html>
